/**
 * 会议信息
 * @author Qasim <15750783791@163.com>
 * @version 2016/9/5
 */
var self = home_info = '';

document.addEventListener('plusready' , ready ,  false);

function ready(){
	 
	self = plus.webview.currentWebview();
	
	//获取缓存的数据
	home_info = plus.storage.getItem('home_info');
	
	if(home_info){//如果有 直接显示
		
		showInfo();
		
	}else{  
		
		toast('没有获取到数据 ,请刷新首页获取最新数据');
		
	}
	
	//搜索
 	$('.search').on('click' , function(){
 		search(26); 
 	})
 	 
	
}


//数据显示在页面
function showInfo(){
		
	plus.nativeUI.showWaiting('加载中...'); 
	
	setTimeout(function(){ 
		
		plus.nativeUI.closeWaiting();
		
	} , 1000);
		
	home_info = $.parseJSON(home_info);
	 
	//会议信息
	if(home_info.meeting_info){
		var flag = true; 
		$.each(home_info.meeting_info , function(k , v){
			if(flag && v.is_top == 1){
				$('.position-re').attr('data-id' , v.id)
				$('.position-re').attr('data-tid' , v.tid)
				$('.title').text(v.title);
				$('.time').text(v.addtime);
				$('.pic').attr('src' , getImgUrl(v.litpic)).css('height' , '170px'); 
				$('.content').html(v.body); 
				flag = false;   
			}else{
				var html  = '<div class="table-view-cell position-re background-w overflow-h home-list home-list-2 margin-bottom-5" data-id="'+v.id+'" data-tid="'+v.tid+'" data-phone="'+v.tid+'">';
					html += '<div class="mui-pull-right "><div><span class="mui-ellipsis-2 font-15 line-h-23 title">'+v.title+'</span>';
					html += '<p class="font-14 color-c addtime">'+(v.name ? v.name : "<br/>")+'</p><span class="font-14 color-c">'+v.addtime+'</span></div></div><div class="mui-pull-left"><img style="height:70px;" src="'+getImgUrl(v.litpic)+'" /><div class="content" style="display:none">'+v.body+'</div></div></div>';
				$('.lists').append(html); 
			} 
		})
		
		//前往会议详情页面
		$('.position-re').unbind();
		$('.position-re').on('click' , function(){
			
			plus.nativeUI.showWaiting('跳转中...');
			var hy_inf = plus.webview.create('hy-inf.html' , 'hy-inf' , {} , {tid : $(this).attr('data-tid') , title : $(this).find('.title').text() , body : $(this).find('.content').html() , aid : $(this).attr('data-id')});
				 
			hy_inf.addEventListener('loaded' , function(){
				hy_inf.show('slide-in-right');
				plus.nativeUI.closeWaiting();			
			})
				 
				 
			
		})
		
	}
}
